<?
/*----------------------------------------------------------------------
          (C) Bobtail-Bear 2006 	小飞熊新一代下载系统
          	代码编写：小飞熊	版权所有：小飞熊[L.F.Bear]
				官方网站/技术支持：http://www.lfbear.cn
------------------------------------------------------------------------
          (C) Bobtail-Bear 2006 	L.F.Bear's New Download Sysytem
          	Powered by L.F.Bear  Copyright L.F.Bear's Home(R)
               Official Web/Support：http://www.lfbear.cn
-----------------------------------------------------------------------*/

//本页脚本功能：软件搜索页面

$thispage="search.php";
require("header.php");

$s_type=$_POST[s_type];
$search=strtolower($_POST[what]);
$softname=$_POST[type_1];
$keyword=$_POST[type_2];
$type_3=$_POST[type_3];
$type_4=$_POST[type_4];
$type_5=$_POST[type_5];
$type_6=$_POST[type_6];
$isclass=$_POST[isclass];
$class_type=$_POST[class_type];
$formindex=$_POST[formindex];
if($_POST[whatis])  {$whatis=$_POST[whatis];$search=strtolower($whatis);}
else if($_GET[whatis]) {$whatis=$_GET[whatis];$search=strtolower($whatis);}
else
{
$whatis=$p_lang[136];
if ($formindex)  unset($s_type);
}

if($_GET[type])
{
$intype=$_GET[type];
$intype==2 ? $chk2=" checked" : $chk1=" checked";
}
else $chk1=" checked";
$main_class_=$_POST[main_class_];
$main_class=$_POST[main_class];
$sub_class=$_POST[sub_class];
$isdate=$_POST[isdate];
$date1=$_POST[date1];
$date2=$_POST[date2];
global $find;global $search;

switch($s_type)
{

case 1:
$times=readf($path_soft."/number");
$times=ceil($times/100);
$x=0;
for($i=1;$i<=$times;$i++)
{
//$i==$times ? $theend=$time%100 : $theend=100;
$thisinfo=@file("cache/soft_list_".$i.".php");
$thisnum=count($thisinfo);
for($j=0;$j<$thisnum;$j++)
{
unset($ta);unset($tb);unset($tc);unset($td);unset($te);unset($tf);unset($tg);unset($findit);
list($ta,$tt,$tb,$tc,$td,$te,$tf,$tg)=explode("|",$thisinfo[$j]);
$tb=strtolower($tb);$tg=strtolower($tg);
//echo $ta."-".$tb."-".$tc."-".$td."-".$te."-".$tf."-".$tg."<br>";
if($softname && (strpos($tb,$search)!==false)) $findit=1;
if($keyword && (strpos($tg,$search)!==false)) $findit=1;
if($isclass)
{
if($class_type==1)
{
if ($main_class_==$td && $findit==1) $findit=1;
else $findit=0;
}
if($class_type==2)
{if ($main_class==$td && $sub_class==$te && $findit==1) $findit=1;
else $findit=0;}
}

if($isdate) {if($findit==1 && $date1<=$tf && $date2>=$tf) $findit=1; else $findit=0;}
if($findit==1) {$find[$x]=$i.",".$j;$x++;$findit=0;}

}
}
if($x==0)
{
	$fb_title1=$p_lang[137];
	$fb_title2=$p_lang[138];
	$fb_msg=$p_lang[139];
	$fb_link="search.php";
	echo("<Meta http-equiv='Refresh' Content='5; Url=search.php'>");
	require("feedback.php");
}
else
{
for($i=0;$i<$x;$i++)
{
$cs=explode(",",$find[$i]);
$findinfo=@file("cache/soft_list_".$cs[0].".php");
$findit=explode("|",$findinfo[$cs[1]]);
showclassname($findit[4],$findit[5]);

unset($stopmsg);
if($findit[1]!=1) $stopmsg=" <font color=red>$p_lang[140]</font>";

if($softname) $findit[2]=str_replace($search,"<font color=red>".$search."</font>",strtolower($findit[2]));

if($keyword) $findit[7]=str_replace($search,"<font color=red>".$search."</font>",strtolower($findit[7]));

$find_show.="<tr><td height=\"25\" align=\"center\">$classname[0]→$classname[1]</td><td><a href=view.php?id=$findit[0] target=\"_blank\">$findit[2]</a>$stopmsg</td><td>$findit[7]</td><td align=\"center\">$findit[6]</td></tr>";
}
print <<<EOT

<table width="780" border="0" align="center" cellspacing="0">
  <tr>
    <td bgcolor="#F4F4F4"><table width="575" border="0" align="center" cellspacing="0">
      <tr>
        <td width="571" height="25"><table width="575" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="32"><img src="$imagepath/h_priont_01.gif" width="32" height="25"></td>
              <td width="63" background="$imagepath/header_mid.gif" class="markedText3">$p_lang[141]</td>
              <td width="450" background="$imagepath/header_mid.gif"><span class="markedText4">$p_lang[142] $x $t_lang[10]</span>&nbsp;&nbsp;&nbsp;&nbsp;[<a href=search.php>$p_lang[143]</a>]</td>
              <td width="25"><img src="$imagepath/h_priont_03.gif" width="25" height="25" /></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td height="500" valign="top" bgcolor="#FFFFFF"><table width="570" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="150" height="25" align="center" class="markedText2">$p_lang[144]</td>
              <td width="230" class="markedText2">$p_lang[145]</td>
   			  <td width="100" class="markedText2">$p_lang[146]</td>
              <td width="90" align="center" class="markedText2">$p_lang[147]</td>
            </tr>
			$find_show
        </table></td>
      </tr>
      <tr>
        <td><table width="575" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="110" height="25" background="$imagepath/header_mid.gif"></td>
              <td width="325" align="center" background="$imagepath/header_mid.gif"></td>
              <td width="140" background="$imagepath/header_mid.gif"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>

EOT;
require("footer.php");
	
}
break;

case 2:
$y=0;
$times_=readf($path_soft."/number");
$times=ceil($times_/100);
if(empty($nowtime)) $nowtime=1;
if($nowtime>$times) $nowtime=$times;
$nowtime==$times ? $theend=$times_ : $theend=$nowtime*100;

for($k=($nowtime-1)*100+1;$k<=$theend;$k++)
{//echo "begin =  $k ; end = $theend<br>";
unset($temp);
$temp=readf($path_soft."/".$k.".php");
$temp=explode("|",$temp);
//echo "内容：".$temp[23]."<br>";
if($type_3 && (strpos(strtolower(chop($temp[23])),$search)!==false || strtolower(chop($temp[23]))==$search)) $findit=1;
if($type_4 && (strpos(strtolower(chop($temp[17])),$search)!==false || strtolower(chop($temp[17]))==$search)) $findit=1;
if($type_5 && (strpos(strtolower(chop($temp[19])),$search)!==false || strtolower(chop($temp[19]))==$search)) $findit=1;
if($type_6 && (strpos(strtolower(chop($temp[46])),$search)!==false || strtolower(chop($temp[46]))==$search)) $findit=1;

if($isclass)
{
if($class_type==1)
{if ($main_class_==$temp[6] && $findit==1) $findit=1;
else $findit=0;}
if($class_type==2)
{if ($main_class==$temp[6] && $sub_class==$temp[7] && $findit==1) $findit=1;
else $findit=0;}
}

if($isdate) {if($findit==1 && $date1<=$temp[5] && $date2>=$temp[5]) $findit=1; else $findit=0;}

if($findit==1) {$find[$y]=$k;$y++;$findit=0;}
}
if($y==0)
{
	$fb_title1=$p_lang[137];
	$fb_title2=$p_lang[138];
	$fb_msg=$p_lang[139];
	$fb_link="search.php";
	echo("<Meta http-equiv='Refresh' Content='3; Url=search.php'>");
	require("feedback.php");
}


else
{
for($i=0;$i<$y;$i++)
{

$findinfo=@readf($path_soft."/".$find[$i].".php");
$findit=explode("|",$findinfo);
showclassname($findit[6],$findit[7]);

if($type_3) $findit[23]=str_replace($search,"<font color=red>".$search."</font>",strtolower($findit[23]));
if($type_4) $findit[17]=str_replace($search,"<font color=red>".$search."</font>",strtolower($findit[17]));
if($type_5) $findit[19]=str_replace($search,"<font color=red>".$search."</font>",strtolower($findit[19]));
if($type_6) $findit[46]=str_replace($search,"<font color=red>".$search."</font>",strtolower($findit[46]));
if($findit[17]=="" || $findit[17]=="0") $findit[17]=$p_lang[148];
if($findit[19]=="" || $findit[19]=="0") $findit[19]=$p_lang[148];
if($findit[46]=="" || $findit[46]=="0") $findit[46]=$p_lang[148];
$find_show.="<tr><td height=\"25\" align=\"center\">$classname[0]→$classname[1]</td><td><a href=view.php?id=$find[$i] target=\"_blank\">$findit[3]</td><td align=\"center\">$findit[5]</td></tr><tr><td colspan=\"3\" height=\"20\">$p_lang[149] $findit[17]&nbsp;&nbsp;&nbsp;$p_lang[150] $findit[19]&nbsp;&nbsp;&nbsp;$p_lang[151] $findit[46]</td></tr><tr><td align=\"left\" colspan=\"3\" height=\"25\">$p_lang[152] $findit[23]</td></tr>";
}
print <<<EOT

<table width="780" border="0" align="center" cellspacing="0">
  <tr>
    <td bgcolor="#F4F4F4"><table width="575" border="0" align="center" cellspacing="0">
      <tr>
        <td width="571" height="25"><table width="575" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="32"><img src="$imagepath/h_priont_01.gif" width="32" height="25"></td>
              <td width="63" background="$imagepath/header_mid.gif" class="markedText3">$p_lang[141]</td>
              <td width="450" background="$imagepath/header_mid.gif"><span class="markedText4">$p_lang[142] $y $t_lang[10]</span>&nbsp;&nbsp;&nbsp;&nbsp;[<a href=search.php>$p_lang[143]</a>]</td>
              <td width="25"><img src="$imagepath/h_priont_03.gif" width="25" height="25" /></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td height="500" valign="top" bgcolor="#FFFFFF"><table width="570" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="150" height="25" align="center" class="markedText2">$p_lang[144]</td>
              <td width="330" class="markedText2">$p_lang[145]</td>
              <td width="90" align="center" class="markedText2">$p_lang[147]</td>
            </tr>
			$find_show
        </table></td>
      </tr>
      <tr>
        <td><table width="575" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="110" height="25" background="$imagepath/header_mid.gif"></td>
              <td width="325" align="center" background="$imagepath/header_mid.gif"></td>
              <td width="140" background="$imagepath/header_mid.gif"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>

EOT;
require("footer.php");
	
}
break;

default:
//为子分类JS调用传递数据
$classfile="include/class.php";
function showclass() {
	$subclassfile="include/subclass.php";
	$downlist=file($subclassfile);
	$fcount=count($downlist);
	for ($i=0; $i<$fcount; $i++) {
$detail=explode("|",$downlist[$i]);
		echo "subcat[$i] = new Array(\"$detail[2]\",\"$detail[1]\",\"$detail[0]\");\n\n";
	}
	echo "onecount=$fcount;\n";
}
//生成主分类部分
unset($mainclass_show);	
$downlist=file($classfile);
	$fcount=count($downlist);
	$mainclass_show="<option selected value=\"\">$p_lang[153]</option>";
	for ($i=0; $i<$fcount; $i++) {
	$detail=explode("|",$downlist[$i]);
	$mainclass_show.="<OPTION VALUE=\"$detail[0]\">$detail[1]</OPTION>";
	$mainclass_show_.="<OPTION VALUE=\"$detail[0]\">$detail[1]</OPTION>";
}
$mainclass_show.="</select>";
//JS实现动态子目录变更

print <<<EOT

<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();

EOT;

showclass();

print <<<EOT

function changelocation(locationid)
{	document.FORM.sub_class.length = 0; 
    var locationid=locationid;
    var i;
    for (i=0;i<onecount; i++)
        {
        	if (subcat[i][1] == locationid)
            {document.FORM.sub_class.options[document.FORM.sub_class.length] = new Option(subcat[i][0], subcat[i][2]);}
		}	if (document.FORM.main_class.options[document.FORM.main_class.selectedIndex].value == "" ) 
			{document.FORM.sub_class.options[document.FORM.sub_class.length] = new Option("$p_lang[154]", "");}
} 

function paste(obj){
obj.select(); 
obj.value=window.clipboardData.getData("Text")
}

function checkform(theform) 
{
	if (theform.what.value=="" || theform.what.value==$p_lang[136]) 
	{
		alert("$p_lang[19] $p_lang[155]");
		return false;
	 }
}

</script>
  <script src="images/calendar.js"></script>
<link href="$imagepath/style.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY onload="FORM.date1.disabled=true;FORM.date2.disabled=true;">
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="32" height="15" align="center" bgcolor="#FFFFFF"><img src="$imagepath/h_priont_01.gif" width="32" height="25"></td>
    <td width="741" align="left" background="$imagepath/header_mid.gif" bgcolor="#FFFFFF">$p_lang[156]</td>
    <td align="center" bgcolor="#FFFFFF"><img src="$imagepath/h_priont_03.gif" width="25" height="25"></td>
  </tr>
  <tr>
    <td height="400" colspan="3" align="center" bgcolor="#FFFFFF">
			<form  name="FORM"  method="post" action="search.php">
  			  <table width="500" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="50" align="center" bgcolor="#99FF00"><input name="what" type="text" id="what" onClick="if(this.value=='$p_lang[136]') this.value='';" value=$whatis size="30"/>
				  <input type="button" name="Submitp" value="$p_lang[157]" title="$p_lang[158]" onClick="paste(what);">
				  <input type="button" name="Submitc" value="$p_lang[159]" title="$p_lang[160]" onClick="what.value='';">				  </td>
                </tr>
                <tr>
                  <td height="20" align="left" bgcolor="#FFFF99"><span class="markedText3">
                    <input name="s_type" type="radio" class="Radio" value="1" checked onClick="complex.disabled=this.checked;easy.disabled=!this.checked;">
                  $p_lang[161]</span></td>
                </tr>
       <tbody id="easy">         <tr>
                  <td height="25" align="center"><input name="type_1" type="checkbox" id="type_1" value="1" class="checkbox" $chk1>
$p_lang[162]
  <input name="type_2" type="checkbox" id="type_2" value="1" class="checkbox" $chk2>
$p_lang[163]</td>
                </tr>
				</tbody>
				<tr>
                  <td height="20" align="left" bgcolor="#FFFF99"><span class="markedText3">
                    <input name="s_type" type="radio" class="Radio" value="2" onClick="easy.disabled=this.checked;complex.disabled=!this.checked;alert('$p_lang[164]')">
                  $p_lang[176]</span></td>
                </tr>
    <tbody id="complex" disabled>            <tr>
                  <td height="25" align="center"><input name="type_3" type="checkbox" id="type_3" value="1" class="checkbox">
$p_lang[165]
  <input name="type_4" type="checkbox" id="type_4" value="1" class="checkbox">
$p_lang[166]
<input name="type_5" type="checkbox" id="type_5" value="1" class="checkbox">
$p_lang[167]
<input name="type_6" type="checkbox" id="type_6" value="1" class="checkbox">
$p_lang[168]</td>
                </tr></tbody>
      <tr>
        <td height="20" align="left" bgcolor="#FFFF99"><span class="markedText3">$p_lang[169]</span></td>
      </tr>
    
				<tr>
                  <td height="25" align="left" bgcolor="#FFCCFF"><input name="isclass" type="checkbox" id="isclass" value="1" class="checkbox" onClick="ct1.disabled=!this.checked;ct2.disabled=!this.checked;if(ct1.checked) main_class_.disabled=0;if(ct2.checked){main_class.disabled=0;sub_class.disabled=0;}if(!this.checked){main_class_.disabled=1;main_class.disabled=1;sub_class.disabled=1}">
$p_lang[170]</td>
                </tr>
                <tr>
                  <td height="50" align="left" bgcolor="#FFCCFF"><input name="class_type" type="radio" disabled class="Radio" id="ct1" onClick="main_class_.disabled=!this.checked;main_class.disabled=this.checked;sub_class.disabled=this.checked" value="1" checked/>$p_lang[171]
                    <select name="main_class_" disabled>
                      $mainclass_show_
                    </select>
                    <br />
                    <input type="radio" name="class_type" id="ct2" value="2" class="Radio" onClick="main_class.disabled=!this.checked;sub_class.disabled=!this.checked;main_class_.disabled=this.checked;" disabled/>$p_lang[172]
                    <select name="main_class" onChange="changelocation(document.FORM.main_class.options[document.FORM.main_class.selectedIndex].value)" disabled>
                      $mainclass_show
                      - <select name="sub_class" disabled>
                      <option selected="selected" value="">$p_lang[154]</option>
                    </select></td>
                </tr>
                <tr>
                  <td height="25" align="left" bgcolor="#CCCCFF"><input name="isdate" type="checkbox" id="isdate" value="1" class="checkbox" onClick="date1.disabled=!this.checked;date2.disabled=!this.checked;">
$p_lang[173]</td>
                </tr>
                <tr>
                  <td height="50" align="left" bgcolor="#CCCCFF">$p_lang[174]
                   <script language=javascript>
  var myDate=new dateSelector();
  myDate.month--;
   myDate.inputName='date1';  
  myDate.display();
</script>
$p_lang[175]
<script language=javascript>
  var myDate=new dateSelector();
  myDate.month;
   myDate.inputName='date2';  
  myDate.display();
</script>
	</td>
                </tr>
				<tr><td align="left" valign="middle" height="25">&nbsp;</td>
				</tr>
                <tr>
                  <td height="35" align="center"><input type="submit" name="Submit" value="$common[submit]" class="Button2" onclick="return checkform(this.form);"/>
                    <input type="reset" name="Submit2" value="$common[reset]" class="Button3" /></td>
                </tr>
          </table>
            </form>	</td>
  </tr>
  <tr>
    <td colspan="3" align="center" bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
</table>
</BODY></HTML>
EOT;
require("footer.php");
break;
}
?>


